﻿/*
____
 L|ypps Web controls for ASP.NET

Copyright (c) 2009 Alessandro Zifiglio, http://www.Typps.com
EMail: alessandro@Typps.com

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
namespace Typps
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    /// <summary>
    /// Provides a type converter that retrieves a list of 
    /// <see cref="T:System.Web.UI.WebControls.HyperLink"></see>
    /// or
    /// <see cref="T:System.Web.UI.HtmlControls.HtmlAnchor"></see>
    /// controls in the current container.
    /// </summary>
    class AssociatedHyperLinkConverter : ControlIDConverter
    {
        #region Constructors

        public AssociatedHyperLinkConverter()
        {
            // constructor
        }

        #endregion Constructors

        #region Methods

        /// <summary>
        /// Indicates whether the provided control inherits from
        /// <see cref="T:System.Web.UI.WebControls.WebControl"></see>.
        /// </summary>
        /// <returns>
        /// true if the control inherits from the 
        /// <see cref="T:System.Web.UI.WebControls.HyperLink"></see>
        /// class; or 
        /// <see cref="T:System.Web.UI.HtmlControls.HtmlAnchor"></see>
        /// otherwise, false.
        /// </returns>
        /// <param name="control">
        /// The control instance to test whether it is a 
        /// <see cref="T:System.Web.UI.WebControls.WebControl"></see>. 
        /// </param>
        protected override bool FilterControl(Control control)
        {
            bool returnValue = false;
            switch (control.GetType().Name)
            {
                case "HyperLink":
                    returnValue = true;
                    break;
                case "HtmlAnchor":
                    returnValue = true;
                    break;
                case "HtmlImage":
                    returnValue = true;
                    break;
                case "TextBox":
                    returnValue = true;
                    break;
                case "Image":
                    returnValue = true;
                    break;
                case "ImageButton":
                    returnValue = true;
                    break;
                case "Label":
                    returnValue = true;
                    break;
                case "LinkButton":
                    returnValue = true;
                    break;
                case "Button":
                    returnValue = true;
                    break;
            }
            return returnValue;
        }

        #endregion Methods
    }
}